import axios from 'axios';
import qs from 'qs';
import url from './url.js'

let ajax = axios.create({
    baseURL: url + '/kingop-new-manager',
    timeout: 30000
})


ajax.defaults.withCredentials = true
ajax.interceptors.request.use(config => {
    if (config.url === 'instmanage/uploadFile') {
        config.headers['Content-Type'] = 'multipart/form-data'
    } else {

        config.headers['Content-Type'] = 'application/x-www-form-urlencoded';

        if (config.method === 'post') {
            config.data = qs.stringify(config.data)
        }
    }

    return config
}, error => {
    loadinginstace.close()
    return Promise.reject(error)
})
export default ajax